<?php 
class ExcelRead {
 public function __construct() {
     /*导入phpExcel核心类    注意 ：你的路径跟我不一样就不能直接复制*/
     include_once(Yii::app()->basePath."/extensions/PHPExcel_1.8.0/Classes/PHPExcel.php"); 
 }
/**
* 读取excel $filename 路径文件名 $encode 返回数据的编码 默认为utf8
*以下基本都不要修改
*/
public function read($filename,$file_type='xlsx',$encode='utf-8'){
          $objReader = PHPExcel_IOFactory::createReader('Excel2007');
          if (strtolower ($file_type) == "xls") {
          $objReader = PHPExcel_IOFactory::createReader('Excel5');
          }
          $objReader->setReadDataOnly(true);
          $objPHPExcel = $objReader->load($filename);
          $objWorksheet = $objPHPExcel->getActiveSheet();
          $highestRow = $objWorksheet->getHighestRow(); 
          $highestColumn = $objWorksheet->getHighestColumn();  
          $highestColumnIndex = PHPExcel_Cell::columnIndexFromString($highestColumn);  
          $excelData = array(); 
          for ($row = 1; $row <= $highestRow; $row++) {
            $temp[$row]=array();
            for ($col = 0; $col < $highestColumnIndex; $col++) {  
                  $temp[$row][$col] =(string)$objWorksheet->getCellByColumnAndRow($col, $row)->getValue(); 
                  
             } $excelData += $temp;
         } 
        return $excelData;
    }    
 }
